#define _CRT_SECURE_NO_WARNINGS	

int exchangeBits(int num)
{
    int tmp1, tmp2;
    for (int i = 0; i < 31; i += 2)
    {
        tmp1 = (num >> i) & 1;
        tmp2 = (num >> (i + 1)) & 1;
        if (tmp1 == 1 && tmp2 == 0)
        {
            num &= ~(1 << i);
            num |= (1 << (i + 1));
        }
        else if (tmp1 == 0 && tmp2 == 1)
        {
            num &= ~(1 << (i + 1));
            num |= (1 << (i));
        }
    }
    return num;
}